//
//  HWMineHeaderView.swift
//  HWPromoteProjectAPP
//
//  Created by 王昌健 on 2022/1/28.
//  Copyright © 2022 王昌健. All rights reserved.
//

import UIKit

class HWMineHeaderView: UICollectionReusableView {
    var imageView:UIImageView!
    var titleLabel:UILabel!
    var model:HWMineNavModel? {
        didSet {
            imageView.sd_setImage(with: URL(string: model?.icon ?? ""), completed: nil)
            titleLabel.text = model?.title
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        initUI()
        
        initFrame()
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

extension HWMineHeaderView {
    private func initUI() -> Void {
        
        backgroundColor = .clear
        
        imageView = UIImageView()
        imageView.backgroundColor = .clear
        addSubview(imageView)
        
        titleLabel = HWLabel.createBoldLabel(title: "", color: "#333333", font: 16*widthScale)
        addSubview(titleLabel)
        
    }
    
    private func initFrame() -> Void {
        imageView.snp.makeConstraints { make in
            make.left.equalTo(40*widthScale)
            make.bottom.equalToSuperview()
            make.width.height.equalTo(20*widthScale)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(imageView.snp.right).offset(6*widthScale)
            make.bottom.equalToSuperview()
        }
        
    }
}
